package com.chen.controller;

import com.chen.dao.MedicalAssayMapper;
import com.chen.entity.Hospital;
import com.chen.entity.MedicalAssay;
import com.chen.service.IhospitalService;
import com.chen.service.MedicalAssayService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;

import java.util.List;

@Controller
public class HospitalController {

    @Autowired
    MedicalAssayService medicalAssayService;
    @Autowired
    IhospitalService ihospitalService;

    @GetMapping("/getAll")
    public String getAll(MedicalAssay medicalAssay, Model model){
        List<MedicalAssay> list = medicalAssayService.getLis(medicalAssay);
        List<Hospital>hospitalName =ihospitalService.list();
        model.addAttribute("list",list);
        model.addAttribute("hoospitalId",medicalAssay.getHoospitalId());
        model.addAttribute("Hospitals",hospitalName);
        return "main";
    }


    /*
    * 添加核酸检查信息
    * */
    @PostMapping("addInfo")
    public String add(MedicalAssay medicalAssay,Model model){
        boolean save = medicalAssayService.save(medicalAssay);
        model.addAttribute("save",save);
        return "add";
    }
}
